package com.example.springbootwebdemo.repository;

import com.example.springbootwebdemo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UsersRepository {
    @Select("select id,username,password,name from user")
    List<User> findAll();

    @Select("select count(1) from user where username=#{user.username} and password=#{user.password}")
    int login(@Param("user") User user);

    @Select("select * from user where id=#{id}")
    @Results({
            @Result(property = "products", column = "id", many = @Many(select = "com.example.springbootwebdemo.repository.ProductRepository.findByUid"))
    })
    User findById(Integer id);
}
